/**
 * Created by ouyang on 2017/3/5.
 */

    //定义通过id获取页面元素的方法
var $ = function (id) {
        return document.getElementById(id);
    };
//定义通过class获取页面元素的方法
var $list = function (div1) {
    return document.getElementsByClassName(div1);
};
//定义窗口的拉伸宽高
var win_width = 0;
var win_height = 0;

//定义一个窗口的方法
var win = function (width, height, title, url) {
    win_width = width;
    win_height = height;

    //背景层
    var back = document.createElement('div');
    back.style.backgroundColor = '#bfbfbf';
    back.style.opacity = '0.6';
    back.style.height = document.documentElement.clientHeight + 'px';
    back.style.width = document.documentElement.clientWidth + 'px';
    back.style.position = 'absolute';
    back.style.left = '0';
    back.style.top = '0';
    back.id = 'back';

    //小窗口
    var tianjia = document.createElement('div');
    tianjia.style.height = height + 'px';
    tianjia.style.width = width + 'px';
    tianjia.style.backgroundColor = '#bababa ';
    tianjia.style.position = 'absolute';
    tianjia.style.top = (document.documentElement.clientHeight - height) / 2 + 'px';
    tianjia.style.left = (document.documentElement.clientWidth - width) / 2 + 'px';
    tianjia.id = 'tianjia';

    //标题栏
    var tianjia1 = document.createElement('div');
    tianjia1.style.borderBottom = '1px solid #6f6f6f';
    tianjia1.textContent = title;
    tianjia.appendChild(tianjia1);


    //窗口的内容
    var form = document.createElement('iframe');
    form.src = 'form.html';
    form.style.height = height - 30 + 'px';
    form.style.width = '580px';
    tianjia.appendChild(form);


    //放置在文档body中
    document.body.appendChild(back);
    document.body.appendChild(tianjia);
};
window.onresize = function () {
    $('back').style.width = document.documentElement.clientWidth + 'px';
    $('back').style.height = document.documentElement.clientHeight + 'px';

    $('tianjia').style.top = (document.documentElement.clientHeight - win_height) / 2 + 'px';
    $('tianjia').style.left = (document.documentElement.clientWidth - win_width) / 2 + 'px';
};